﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Ivory;
using Ivory.GUI;
using Jitter;
using Jitter.Collision;
using CrystalCore.Mapping;
using CrystalCore;

namespace CrystalCore.Structure
{
    public class BarvaLevel : GameScreen
    {
        public static readonly string Key = "##:BARVALEVEL:##";
        public static string LevelFile = null;

        //Fields
        private GUI _LevelInterface;

        //cTor
        public BarvaLevel(Game game)
            : base(game)
        {

        }

        //Methods        
        public override void RenderGame(SpriteBatch batch, GameTime time)
        {

        }    
        public override void UpdateGame(GameTime time, InputControl input)
        {

        }
        
        public override void RenderUI(SpriteBatch batch, GameTime time)
        {
            batch.Begin();
            _LevelInterface.DrawGUI(batch, time);
            batch.End();
        }
        public override void UpdateUI(GameTime time, InputControl input)
        {
            _LevelInterface.UpdateGUI(input, time);
        }

        public override bool PreloadAssets()
        {
            //Things to be loaded when the game startups, not for each level
            //E.g. GameMenus / Load Screen!!!

            return true;
        }
        public override bool LoadData()
        {
            //Assign Globals
            ObjectHolder.GameWorld = new World(new CollisionSystemSAP());
            ObjectHolder.GameWorld.Gravity = new Jitter.LinearMath.JVector(0);

            //ObjectHolder.GameCamera = new CrystalCore.Libs.GameCamera(Game);
            ObjectHolder.GlobalDebugRenderer = new CrystalCore.Libs.DebugDrawer(Game);
            ObjectHolder.GlobalDebugRenderer.Initialize();
            
            //Game Data

            //GUI
            _LevelInterface = new GUI();

            return true;
        }
    }
}
